import { StorageNameEnums } from '@/enums'
import { useLocalStorageState } from 'ahooks'

export default function useTools() {
  const [, setUserInfo] = useLocalStorageState(StorageNameEnums.UserInfo)
  const [, setToken] = useLocalStorageState(StorageNameEnums.Token)
  const [, setTokenName] = useLocalStorageState(StorageNameEnums.TokenName)

  function logoOutHandler() {
    // 清除 token
    setToken()
    setTokenName()
    // 清除 userInfo
    setUserInfo()
  }

  return {
    logoOutHandler
  }
}
